﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CompareCopy
{
    class Tools
    {
        /// <summary>  
        /// 转换文件尺寸表示方法  
        /// </summary>  
        /// <param name="size">字节值</param>  
        /// <returns></returns>  
        public static String HumanReadableFilesize(double size)
        {
            String[] units = new String[] { "B", "KB", "MB", "GB", "TB", "PB" };
            double mod = 1024.0;
            int i = 0;
            while (size >= mod)
            {
                size /= mod;
                i++;
            }
            return Math.Round(size) + units[i];
        }
    }
}
